/**
 * 
 */
package pt.inescid.components.console.commands;

import java.util.ArrayList;
import java.util.List;

import pt.inescid.components.console.Console;


/**
 * @author Sergio Esteves
 *
 */
public class SubmitJobCommand extends Command {

	public static final String CMD_NAME = "submit_job";
	
	public SubmitJobCommand(Console console) {
		super(console);
	}
	
	@Override
	public String getCmdName() {
		return CMD_NAME;
	}
	
	@Override
	public String synopsis() {
		return CMD_NAME + " appID input_file_1 ... input_file_n output_file_name" + SYNTAX_SEPARATOR + 
		"Submits a job with the given application identifier, input file locations, and output file name";
	}

	@Override
	public void execute(String[] args) throws CommandException {
		validateArgs(args, 3,-1);
		List<String> input = new ArrayList<String>();
		for(int i = 2; i < args.length - 1; i++)
			input.add(args[i]);		
		gridP2P.createJob(args[1], input, args[args.length - 1]);		
	}
}
